package com.ruoyi.demo.controller.MeetingRoomAdministrator;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.demo.domain.vo.meetLogVO;
import com.ruoyi.demo.service.IManagerMeetLogService;
import com.ruoyi.system.domain.MeetLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.page.PageDomain;

import java.util.List;

/**
 * @author 33692
 */
@RestController
@RequestMapping("/demo/meetLog")
public class ManagerMeetLogController extends BaseController {

    @Autowired
    private IManagerMeetLogService managerMeetLogService;

    /**
     * 会议室使用日志
     */
//    @PreAuthorize("@ss.hasPermi('demo:meetLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(MeetLog meetLog)
    {
        // 先获取总数
        List<meetLogVO> allList = managerMeetLogService.selectMeetLogList(meetLog);
        long total = allList.size();

        // 获取分页参数
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();

        // 手动设置分页
        PageHelper.startPage(pageNum, pageSize);
        List<meetLogVO> list = managerMeetLogService.selectMeetLogList(meetLog);

        // 创建自定义的分页信息
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(0);
        rspData.setRows(list);
        rspData.setTotal(total);

        return rspData;
    }
}